<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1 id="app">
    日期：{{dateStr}}
</h1>
<script src="./node_modules/vue/dist/vue.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el:"#app",
        data:{
            date:1529032123201, // 时间毫秒
            dateStr:"",
            person: {
                name:''
            }
        },
        watch:{
            date:{ // 监控date的变化
                deep:true,
                handler(newVal,oldVal){
                    console.log(newVal);
                    console.log(oldVal);
                    const d = new Date(this.date);
                    this.dateStr = d.getFullYear() + "年" + d.getMonth() + "月" + d.getDay() + "日";
                }
            },
            person:{
                deep:true,
                handler(val){
                    console.log(val.name);
                }
            },
            "person.name":{ // 监听person的name,person是一个对象

            }
        }
    })
</script>
</body>
</html>
